package com.leha.forum.lehare.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.leha.forum.lehare.entity.Notification;
import com.leha.forum.lehare.mapper.NotificationMapper;
import com.leha.forum.lehare.service.NotificationService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lovelycat
 * @version 1.0
 * @since 2025-04-27 21:13
 */
@Service
public class NotificationServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements NotificationService {
    @Override
    public boolean sendNotification(Long userId, String content) {
        return save(new Notification(null, userId, content, System.currentTimeMillis()));
    }

    @Override
    public List<Notification> getUserNotifications(Long userId) {
        return list(new QueryWrapper<Notification>().eq("user_id", userId));
    }
}
